package com.whisper.hfdp.mq.scheduled;

import com.whisper.hfdp.mq.MqConstant;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class ScheduledProducer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer(MqConstant.GROUP);
        producer.setNamesrvAddr(MqConstant.NAMESRV_ADDR);
        producer.start();

        for (int i = 0 ; i < 10; i ++) {
            String body = "hello " + i;
            Message message = new Message(MqConstant.TOPIC, "TAG-1", body.getBytes(StandardCharsets.UTF_8));
            message.setDelayTimeLevel(3);
            producer.send(message);
        }

        producer.shutdown();
    }
}
